package com.atguigu.spzx.service.utils;

import com.atguigu.spzx.model.entity.user.UserInfo;

/**
 * ClassName: AuthContextUtils
 * Package: com.atguigu.spzx.service.utils
 * Description:
 *          认证上下文，用线程本地变量来保存用户信息
 * @Author 刘强
 * @Create 2024/7/16 19:51
 * @Version 1.0
 */

public class AuthContextUtils {
    private static ThreadLocal<UserInfo>  threadLocal = new ThreadLocal<>();

    public static void set(UserInfo userInfo){
        threadLocal.set(userInfo);
    }
    public static UserInfo get(){
        return threadLocal.get();
    }
    public static void remove(){
        threadLocal.remove();
    }
}
